package com.yunyao.dao.service.bamu.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.model.BamuPoSupplyMaterial;
import com.yunyao.dao.model.BamuSoSupplyMaterial;
import com.yunyao.dao.mapper.BamuSoSupplyMaterialMapper;
import com.yunyao.dao.service.bamu.IBamuSoSupplyMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 合同材料表 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuSoSupplyMaterialServiceImpl extends ServiceImpl<BamuSoSupplyMaterialMapper, BamuSoSupplyMaterial> implements IBamuSoSupplyMaterialService {

    @Override
    public List<BamuSoSupplyMaterial> listBySupplyId(String reconciliationId) {
        return null;
    }

    @Override
    public List<BamuSoSupplyMaterial> listByReconciliationId(String supplyId) {
        // 检查对账ID是否为空或空白，如果是，则直接返回一个空列表
        if (StringUtils.isBlank(supplyId)) {
            return List.of();
        }
        // 构建查询条件，包括对账ID和材料未被删除的状态
        LambdaQueryWrapper<BamuSoSupplyMaterial> wrapper =
                new LambdaQueryWrapper<BamuSoSupplyMaterial>().eq(BamuSoSupplyMaterial::getSupplyId, supplyId)
                        .eq(BamuSoSupplyMaterial::getIsDeleted,
                                DataDeletedStatus.NO.getType());
        // 执行查询并返回结果
        return list(wrapper);
    }
}
